package com.sctvcloud.dongqu.ui.dialog;

import android.app.Dialog;
import android.os.Bundle;
import android.os.Message;
import android.view.View;

import com.ruihang.generalibrary.ui.dialog.BaseDialogFragment;
import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.sctvcloud.dongqu.R;

/**
 * Created by Administrator on 2017/6/23 0023.
 */

public class ShowDiaFragment extends BaseDialogFragment implements View.OnClickListener {
    private CustomFontTextView cancel_cv, sure_cv, content_cv;
    public static final int LOGINOUT_TAG = 404;
    public static final int PHONE_TAG = 505;
    public static final int NOTIFICATION_TAG =606;
    private int type = 0;

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
    protected int getContentRes() {
        return R.layout.dia_show_fragment;
    }

    @Override
    protected void initViews(Dialog dialog, Bundle savedInstanceState) {
        cancel_cv = (CustomFontTextView) dialog.findViewById(R.id.dia_show_cancel);
        sure_cv = (CustomFontTextView) dialog.findViewById(R.id.dia_show_sure);
        content_cv = (CustomFontTextView) dialog.findViewById(R.id.content_show);
        if(type==0){
            content_cv.setText(getString(R.string.login_out));
        }else if(type==1){
            content_cv.setText(getString(R.string.phone));
        }else if(type==2){
            content_cv.setText(R.string.open_notifition);
        }
        cancel_cv.setOnClickListener(this);
        sure_cv.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        if (v == cancel_cv) {
            dismissAllowingStateLoss();
        } else if (v == sure_cv) {
            if (callBack != null) {
                Message message = new Message();
                if (type == 0) {
                    message.what = LOGINOUT_TAG;
                } else if (type == 1) {
                    message.what = PHONE_TAG;
                }else if(type==2){
                    message.what=NOTIFICATION_TAG;
                }
                callBack.onCallBackMsg(this, message);
                dismissAllowingStateLoss();
            }
        }
    }

//    @Override
//    public void onResume() {
//        super.onResume();
//        switch (type) {
//            case 0:
//                content_cv.setText(getString(R.string.login_out));
//                break;
//            case 1:
//                content_cv.setText(getString(R.string.phone));
//                break;
//
//        }
//    }

}
